<template>
	<view class="index">
		<block v-if="show">
			<movable-area class="car-btn" :style="{top: top + 'px'}">
				<movable-view direction="all" class="car-btn-img">
					<image :lazy-load="true" src="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/index/car.png"
						@click="goCar"></image>
				</movable-view>
				<!-- <movable-view direction="all" class="course-btn-img">
					<image :lazy-load="true"
						src="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/static/images/other/2021-04-08/20210408/4c77262ae011e96d16303b275a93ce29.png"
						@click="goCourse"></image>
				</movable-view> -->
			</movable-area>
			<view class="index-custom-theme">
				<image :src="head_img" class="head_img" :style="{height: head_img_height + 'px'}"></image>
				<view class="navbar">
					<!-- #ifdef MP-WEIXIN -->
					<u-navbar :title="userInfo.store_name" title-width="400" :is-back="false" title-size="38rpx"
						:title-color="titleColor" :background="background" :border-bottom="false">
						<block v-if="!isCustom">
							<image :lazy-load="true"
								src="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/index/search.png" class="search"
								@click="search">
							</image>
						</block>
						<block v-else>
							<image :lazy-load="true"
								src="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/index/search-light.png"
								class="search" @click="search">
							</image>
						</block>
					</u-navbar>
					<!-- #endif -->
					<!-- #ifdef APP-PLUS || H5 -->
					<u-navbar :title="userInfo.store_name" title-width="400" :is-back="false" title-size="38rpx"
						:title-color="titleColor" :background="background" :border-bottom="false">
						<block v-if="!isCustom">
							<image :lazy-load="true"
								src="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/index/scanning.png"
								class="scanning" @click="imgSearch"></image>
							<image :lazy-load="true"
								src="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/index/search.png" class="search"
								@click="search" slot="right"></image>
						</block>
						<block v-else>
							<image :lazy-load="true"
								src="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/index/scanning-light.png"
								class="scanning" @click="imgSearch"></image>
							<image :lazy-load="true"
								src="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/index/search-light.png"
								class="search" @click="search" slot="right"></image>
						</block>
					</u-navbar>
					<!-- #endif -->
				</view>
				<!-- <view style="padding: 30rpx; position: relative; z-index: 100;" @click="goTieIn">搭配助手</view> -->
				<view class="store-info" v-if="storeInfo">
					<view class="store-info-top">
						<image :src="storeInfo.store_logo" mode="aspectFit" class="logo"></image>
						<view class="store-info-right">
							<view class="store-name">
								<view class="name">{{storeInfo.store_name}}</view>
								<view class="phone"><image src="../../static/svg/icon1.svg"></image>电话:{{storeInfo.phone}}</view>
							</view>
							<view class="store-address">{{storeInfo.province_name}}{{storeInfo.city_name}}{{storeInfo.area_name}}{{storeInfo.address}}</view>
						</view>
					</view>
					<view class="store-info-bot">
						<view class="enter" @click="goStoreInfo"><image src="../../static/svg/icon2.svg"></image>店铺信息</view>
						<view class="enter" @click="goStorePoster"><image src="../../static/svg/icon3.svg"></image>店铺海报</view>
					</view>
				</view>
				<!-- 套餐轮播 -->
				<view class="index-package">
					<view class="index-package-tabs">
						<u-tabs :list="packageList" :current="packageIndex" @change="packageTabChange" :inactive-color="tabsColor"
							:active-color="tabsActiveColor" font-size="28" :bg-color="tabsBackgroundColor"></u-tabs>
					</view>
					<view class="index-package-swiper" :style="cusTomBackground">
						<u-swiper class="z-index" :list="packageSwiperList" :effect3d="true" :autoplay="false" :circular="true"
							mode="number" indicator-pos="bottomRight" :isPackage="true" height="810" bg-color="#F8F8F8"
							border-radius="16" name="url" :currentid="packageCurrent" @click="goStyleList"
							@change="packageChange"></u-swiper>
					</view>
					<view class="shadow" v-if="packageSwiperList.length" :style="cusTomBottom">
						<image :lazy-load="true"
							src="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/index/shadow.png"></image>
					</view>
				</view>
				<view class="index-step" :style="cusTomPaddingBottom">
					<pt-step :list="indexStep" :color="customColor" :size="customSize"></pt-step>
				</view>
			</view>
			<view class="index-classify-x" v-if="!isCustom">
				<pt-sort-scroll :classifyXList="classifyXList" @Function="jumpSpaceList(arguments)"></pt-sort-scroll>
			</view>
			<!-- <view class="top-brand-img">
				<image 
					src="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/static/images/other/2022-03-15/20220315/9a99e0beac3432bce362ef20659e4d70.png" 
					mode="widthFix">
				</image>
			</view> -->
			<view class="index-area">
				<view class="index-area-list" style="flex: 1;">
					<view class="index-area-item" @click="Recommend(data.shelf_id,-1,data.name,data.is_meal,data)"
						v-for="(data,index) in tab_list" :key="index">
						<image :lazy-load="true" :src="data.url" mode="widthFix"></image>
					</view>
				</view>
			</view>
			<!-- <view class="index-area" v-else>
				<view class="index-area-left">
					<view class="skill-tit">
						<view class="name">{{killData.name}}</view>
						<view class="skill-more" @click="Recommend(killData.shelf_id,-1,killData.name)">更多 <u-icon
								name="arrow-right-fill"></u-icon></view>
					</view>
					<view class="count-down"><u-count-down :timestamp="killCountDown" height="36" bg-color="#FFF"
							font-size="24"></u-count-down></view>
					<view class="skill-items">
						<view class="skill-item" v-for="(data,index) in killData.data" :key="index"
							@click="goProductInfo(data.goods_id)">
							<image :src="data.image"></image>
							<view class="item-info">
								<view class="name">{{data.goods_name}}</view>
								<view class="price">
									<text class="current-price"><text>￥</text>{{data.activity_price}}</text>
									<text class="del-price">￥{{data.market_price}}</text>
								</view>
							</view>
						</view>
					</view>
				</view>
				<view class="index-area-right">
					<view class="area-right-item" v-for="(data,index) in tab_list.slice(0,3)" :key="index"
						@click="Recommend(data.shelf_id,-1,data.name,data.is_meal,data)">
						<image :src="data.url"></image>
					</view>
				</view>
			</view> -->
			<view class="advanced-enter" @click="goAdvanced" v-if="seniorImg">
				<image :src="seniorImg" mode="widthFix"></image>
			</view>
			<view class="index-white-raidus"></view>
			<!-- <view class="index-square-enter">
				<pt-title :name="square_data.name" :subName="square_data.subtitle" padding="0 30rpx 30rpx" @more="moreSquare">
				</pt-title>
				<view class="index-square-list">
					<view class="index-square-item" v-for="(data,index) in square_data.data" :key="index"
						@click="goSquareInfo(data.square_id)">
						<view class="view-times"><u-icon name="eye"></u-icon>{{data.click}}</view>
						<image mode="aspectFill" :src="data.cover_img"></image>
						<view class="square-name">{{data.title}}</view>
						<view class="square-des">{{data.content}}</view>
					</view>
				</view>
			</view>
			<view class="index-adbanner" v-if="advertising.img">
				<pt-adbanner :src="advertising.img" :url="advertising.url" @click="goUrl"></pt-adbanner>
			</view> -->
			<view :style="{marginTop: !advertising.img?'-30rpx':'0'}">
				<view v-for="(data,index) in shelf_list" :key="index">
					<!-- 套餐模板 -->
					<view class="index-house" v-if="data.type==1 || data.type==2 || data.type==24">
						<pt-title :name="data.name" :subName="data.subtitle" @more="morePackage(data.type)">
						</pt-title>
						<view class="index-house-list" v-if="data.data.length">
							<pt-package-vr :list="data.data" @addFoot="packageAddFoot(data.type)" :isLogin="isLogin"></pt-package-vr>
						</view>
						<pt-nothing text="暂无数据" bgColor="#FFFFFF" v-if="!data.data.length"></pt-nothing>
						<pt-scroll-more :text="'左滑查看更多'"
							:icon="'https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/index/arrow-pointer.png'"
							:width="32" :height="26" v-if="data.data.length"></pt-scroll-more>
					</view>
					<!-- 超值推荐、颜值推荐、床垫专区模板 -->
					<view class="index-recommend" v-if="data.type==3 || data.type==4 || data.type==23">
						<pt-title :name="data.name" :subName="data.subtitle" @more="Recommend(data.shelf_id,data.type,data.name)">
						</pt-title>
						<view class="index-recommend-list" v-if="data.data.length">
							<pt-recommend-pro @Recommend="Recommend(data.shelf_id)" :list="data.data" :first="{image: data.image}"
								@GoInfoAddFoot="GoInfoAddFoot(data.name)" :isLogin="isLogin" :type="data.type">
							</pt-recommend-pro>
						</view>
						<pt-nothing text="暂无数据" bgColor="#FFFFFF" v-if="!data.data.length"></pt-nothing>
					</view>
					<!-- 新品专区模板 -->
					<view class="index-NewProducts" v-if="data.type==5">
						<pt-title :name="data.name" :subName="data.subtitle" @more="Recommend(data.shelf_id,data.type,data.name)">
						</pt-title>
						<block v-if="data.data.length">
							<pt-new-pro :list="data.data" :isLogin="isLogin">
							</pt-new-pro>
						</block>
						<pt-nothing text="暂无数据" bgColor="#FFFFFF" v-if="!data.data.length"></pt-nothing>
						<pt-scroll-more :text="'探索更多'"
							:icon="'https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/index/arrow-orange.png'"
							:width="16" :height="22" :isBox="true" @Func="Recommend(data.shelf_id,data.type,data.name)"
							v-if="data.data.length">
						</pt-scroll-more>
					</view>
					<!-- 品牌推荐模板 -->
					<view class="index-brand" v-if="data.type==6">
						<pt-title :name="data.name" :subName="data.subtitle" @more="moreBrand">
						</pt-title>
						<view class="index-brand-list">
							<view class="shadow">
								<view class="index-brand-tabs">
									<view :class="['index-brand-tabs-item',{active: brandIndex==bIndex}]"
										v-for="(item,bIndex) in data.data" :key="bIndex" @click="changeBrandType(bIndex,item.shelf_tab)">
										{{item.name}}
									</view>
								</view>
								<pt-brand-list :list="brandList" v-if="brandList.length"
									@brandAddFoot="brandAddFoot($event)"></pt-brand-list>
								<pt-nothing text="暂无数据" bgColor="#FFFFFF" v-if="!brandList.length"></pt-nothing>
							</view>
						</view>
					</view>
					<!-- VR模板 -->
					<!-- #ifdef H5 || APP-PLUS -->
					<view class="index-vr" v-if="data.type==7 || data.type==10">
						<pt-title :name="data.name" :subName="data.subtitle" @more="moreVr(data.type)">
						</pt-title>
						<pt-var :list="data.data" @Func="goVrInfo($event,data.type)" v-if="data.data.length"
							:isVr="data.type==7?true:false"></pt-var>
						<pt-nothing text="暂无数据" bgColor="#FFFFFF" v-if="!data.data.length"></pt-nothing>
					</view>
					<!-- #endif -->
					<!-- #ifdef MP -->
					<view class="index-vr" v-if="data.type==10">
						<pt-title :name="data.name" :subName="data.subtitle" @more="moreVr(data.type)">
						</pt-title>
						<pt-var :list="data.data" @Func="goVrInfo($event,data.type)" v-if="data.data.length"
							:isVr="data.type==7?true:false"></pt-var>
						<pt-nothing text="暂无数据" bgColor="#FFFFFF" v-if="!data.data.length"></pt-nothing>
					</view>
					<!-- #endif -->
					<!-- 限时特价模板 -->
					<view class="index-limited-time-special" v-if="data.type==11">
						<pt-title :name="data.name" :subName="data.subtitle" :showTimeDown="data.data.length?true:false"
							@more="Recommend(data.shelf_id,data.type,data.name)">
						</pt-title>
						<pt-sale :list="data.data" name="特价" @GoInfoAddFoot="GoInfoAddFoot(data.name)" :isLogin="isLogin"></pt-sale>
					</view>
					<!-- 换购特区模板 -->
					<view class="index-redemption" v-if="data.type==12">
						<pt-title :name="data.name" :subName="data.subtitle" @more="Recommend(data.shelf_id,data.type,data.name)">
						</pt-title>
						<pt-redemption :list="data.data" name="换购" @GoInfoAddFoot="GoInfoAddFoot(data.name)"
							:isLogin="isLogin"></pt-redemption>
					</view>
					<!-- 畅销榜模板 -->
					<view class="index-hotsale" v-if="data.type==13">
						<pt-title :name="data.name" :subName="data.subtitle" @more="Recommend(data.shelf_id,data.type,data.name)">
						</pt-title>
						<!-- <pt-hotsale :list="data.data" name="畅销" @GoInfoAddFoot="GoInfoAddFoot(data.name)"></pt-hotsale> -->
						<pt-new-pro :list="data.data" :isLogin="isLogin" showIndex>
						</pt-new-pro>
						<pt-scroll-more :text="'探索更多'"
							:icon="'https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/index/arrow-orange.png'"
							:width="16" :height="22" :isBox="true" @Func="Recommend(data.shelf_id,data.type,data.name)"
							v-if="data.data.length">
						</pt-scroll-more>
					</view>
				</view>
			</view>
			<block v-for="(data,index) in boutique.list" :key="data">
				<view class="index-products">
					<pt-title :name="data.name" :subName="data.subtitle" :isRight="false"></pt-title>
					<view class="index-products-tabs">
						<u-tabs :list="data.space_list" :current="data.productsIndex?data.productsIndex:0"
							@change="productsTabChange($event,index,data.space_list)" active-color="#141414" inactive-color="#666666"
							font-size="28" gutter="40" :showBar="false" name="space_name">
						</u-tabs>
					</view>
					<view class="index-products-items" v-for="(item,i) in data.shelf_space" :key="i"
						v-if="data.shelf_space.length">
						<pt-product-items :object="item" @goClass="goClass(arguments,i,data.shelf_id)" :index="i" :isHigh="true"
							:noMore="item.goods_list.length?false:true" @moreProducts="moreProducts"
							@GoInfoAddFoot="GoRecommentInfoAddFoot" @moreSpace="moreSpace(arguments)" :isLogin="isLogin">
						</pt-product-items>
					</view>
					<pt-nothing text="暂无数据" bgColor="#FFFFFF" :isHigh="true" v-if="!data.shelf_space.length"></pt-nothing>
				</view>
			</block>
			<!-- 用户绑定微信弹窗-->
			<uni-popup ref="bindUserInfo" type="center">
				<view class="bindUserInfo">
					<button @click="bindwx">
						<image :lazy-load="true"
							src="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/phone_auth.png?v=1"></image>
					</button>
				</view>
			</uni-popup>
			<!-- 用户绑定微信弹窗-->
			<!-- 推送弹窗-->
			<uni-popup ref="eventsPop" type="center" @change="closeEventsPop">
				<view class="eventsPop-list">
					<block v-if="eventsList.length==1">
						<image :lazy-load="true" v-for="(data,index) in eventsList" :key="index" :src="data.image"
							style="width: 600rpx; height: 860rpx; border-radius: 16rpx;" @click="goEvent(index)">
						</image>
					</block>
					<block v-else>
						<u-swiper :list="eventsList" name="image" :isEvents="true" height="860" mode="number" :autoplay="false"
							@click="goEvent"></u-swiper>
					</block>
				</view>
			</uni-popup>
			<!-- 推送弹窗-->
		</block>
		<u-tabbar :list="tabbarList" :icon-size="52" :height="100" active-color="#f59359"></u-tabbar>
		<!-- App端更新提醒 -->
		<uni-popup type="center" ref="Update" :maskClick="false">
			<view class="update-pop">
				<view class="update-close"><u-icon name="close-circle" color="#FFFFFF" class="close" size="60"
						@click="closeUpdate"></u-icon></view>
				<image :lazy-load="true"
					src="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/index/update.png" class="update-img"
					@load="loadUpDateImg" :style="{height: UpDateImgHeight + 'rpx'}">
				</image>
				<view class="update-main">
					<view class="update-tit">更新内容：</view>
					<view class="update-p" v-for="(data,index) in updateContent" :key="index">{{data}}</view>
					<button type="primary" class="download" @click="updateApp">立即更新</button>
				</view>
			</view>
		</uni-popup>
		<pt-loading></pt-loading>
	</view>
</template>

<script>
	import FormData from '@/api/http.interceptor.js'
	export default {
		data() {
			return {
				show: false,
				userInfo: {
					store_name: '深哥家居'
				},
				top: 0,
				background: {
					backgroundColor: '#F8F8F8'
				},
				head_bg: '',
				head_img: '',
				titleColor: '#000000',
				tabsActiveColor: '#141414',
				tabsColor: '#666666',
				tabsBackgroundColor: '#F8F8F8',
				isCustom: false,
				customColor: '',
				customSize: '',
				head_img_height: 0,
				// adbanner
				advertising: {
					img: '',
					url: ''
				},
				// 套餐Tab
				packageIndex: 0,
				packageList: [],
				// #ifdef APP-PLUS || MP-WEIXIN
				packageCurrent: 0, // APP或者微信小程序版此参数为Number
				// #endif
				// #ifdef H5
				packageCurrent: '0', // H5版此参数为string
				// #endif
				// 套餐轮播列表
				packageSwiperList: [],
				// 说明列表
				indexStep: [],
				// 首页分类列表
				classifyXList: [],
				// 推荐四图
				tab_list: [],
				// 货架
				shelf_list: [],
				// 品牌推荐
				brandIndex: 0,
				brandList: [],
				// 精品推荐
				index: 0,
				space_id: '',
				class_id: [{
					space_id: '',
					class_id: ''
				}, {
					space_id: '',
					class_id: ''
				}, {
					space_id: '',
					class_id: ''
				}, {
					space_id: '',
					class_id: ''
				}, {
					space_id: '',
					class_id: ''
				}],
				class_list: [],
				limit: 9,
				boutique: [],
				x: 0,
				y: 0,
				// 图片上传地址
				action: `${this.$domain}/api/Upimg/UpImg`,
				formData: FormData.sign(),
				code: '',
				// 足迹参数
				addFootParam: {
					start_time: '',
					end_time: '',
					stay_time: 0
				},
				// APP端更新内容
				updateContent: ['1.优化了某些方案', '2.优化了某些流程', '3.修复部分已知BUG'],
				// 首页参数
				showHome: false,
				isScroll: false,
				// 底部导航栏
				tabbarCurrent: 0,
				tabbarList: [],
				// 案例参数
				caseNavHeight: 0,
				statusBarHeight: 0,
				caseSort: [],
				caseStyleId: '',
				caseIndex: 0,
				caseList: [],
				casePage: 0,
				isLoading: false,
				noCaseMore: false,
				timer: '',
				eventsList: [],
				Refresh: false,
				downLoadUrl: '',
				UpDateImgHeight: 300,
				parent_id: '',
				square_data: '',
				isLogin: false,
				killData: '',
				killCountDown: 0,
				seniorImg: '',
				storeInfo: ''
			}
		},
		onLoad(options) {
			// APP端更新提醒
			// #ifdef APP-PLUS
			// console.log(plus.runtime)
			this.Update()
			// #endif
			if (options.parent_id) {
				this.parent_id = options.parent_id
				uni.setStorageSync('parent_id', options.parent_id)
				// 如果用户从分享的小程序卡片点击进来的,设置一个url缓存,登录后返回当前缓存url
				let pages = getCurrentPages();
				let curPage = pages[pages.length - 1];
				uni.setStorageSync('newurl', curPage.$page.fullPath)
				this.$u.api.binding_refer({
					id: options.parent_id
				}).catch(() => {
					console.log('接口报错：绑定失败')
					// uni.showToast({
					// 	icon: 'none',
					// 	title: '绑定失败'
					// })
				})
			}
			// 通过场景二维码进入
			let scene
			if (options.scene) {
				scene = decodeURIComponent(options.scene)
				console.error(scene,'scenescenescenescenescenescenescene')
				this.parent_id = this.filterUrlParam(scene).parent_id
				uni.setStorageSync('parent_id', this.filterUrlParam(scene).parent_id)
				// 如果用户从分享的小程序卡片点击进来的,设置一个url缓存,登录后返回当前缓存url
				let pages = getCurrentPages();
				let curPage = pages[pages.length - 1];
				uni.setStorageSync('newurl', curPage.$page.fullPath)
				this.$u.api.binding_refer({
					id: this.filterUrlParam(scene).parent_id
				}).catch(() => {
					console.log('接口报错：绑定失败')
				})
			}
			// #ifdef H5
			if (uni.getStorageSync('tabbarCurrent') != null) {
				this.tabbarCurrent = uni.getStorageSync('tabbarCurrent')
			}
			// #endif
			// #ifdef MP-WEIXIN
			if (uni.getExtConfigSync().appid === 'wx9f2da8a90bb750f7') {
				if (uni.getStorageSync('userInfo')) {
					uni.switchTab({
						url: '/pages/merchant/merchant'
					})
				} else {
					uni.switchTab({
						url: '/pages/classify/classify'
					})
				}
				return
			}
			if (uni.getStorageSync('userInfo')) {
				this.$u.api.StoreShow().then(res => {
					if (res.datas.is_show == 2) {
						uni.switchTab({
							url: '/pages/merchant/merchant'
						})
					}
				})
			}
			// #endif
			this.init()
		},
		watch: {
			show(newValue, oldValue) {
				if (newValue) {
					this.$u.api.ShowLists().then(res => {
						if (res.datas.length) {
							this.eventsList = res.datas
							this.$refs.eventsPop.open()
						} else {
							if (this.userInfo) {
								this.getNotice()
							}
						}
					})
				}
			}
		},
		onShow() {
			this.addFootParam.start_time = parseInt(new Date().getTime() / 1000)
			// #ifdef MP-WEIXIN
			if (uni.getExtConfigSync().appid === 'wx9f2da8a90bb750f7') {
				return
			}
			// #endif
			if (uni.getStorageSync('userInfo')) {
				this.isLogin = true
				this.userInfo = JSON.parse(uni.getStorageSync('userInfo'))
				this.getStoreInfo()
			}
			this.getHome()
			if (!this.show) {
				this.init()
				this.IndexKillList()
			}
			if (uni.getStorageSync('userInfo')) {
				this.getShare()
			}
			// #ifdef MP-WEIXIN || APP-PLUS
			// 每次进入首页判断用户是否绑定了微信信息，如果没有绑定就弹窗提示
			// if (this.show) {
			// 	if (this.userInfo.token) {
			// 		// #ifdef MP-WEIXIN
			// 		if ((!this.userInfo.nickname && !this.userInfo.heard_img) || !this.userInfo.form_id) {
			// 			this.$refs.bindUserInfo.open()
			// 		} else if ((this.userInfo.nickname == 0 && this.userInfo.heard_img == 0) || !this.userInfo.form_id) {
			// 			this.$refs.bindUserInfo.open()
			// 		}
			// 		// #endif
			// 		// #ifdef APP-PLUS
			// 		if (!this.userInfo.nickname && !this.userInfo.heard_img) {
			// 			this.$refs.bindUserInfo.open()
			// 		} else if (this.userInfo.nickname == 0 && this.userInfo.heard_img == 0) {
			// 			this.$refs.bindUserInfo.open()
			// 		}
			// 		// #endif
			// 	}
			// }
			// #endif
			// 此处防止用户未登录时点击小程序右上角胶囊重新进入小程序
			if (!uni.getStorageSync('userInfo')) {
				// #ifdef MP-WEIXIN
				setTimeout(() => {
					if (uni.getStorageSync('review')) {
						if (uni.getExtConfigSync().appid === 'wx9f2da8a90bb750f7') {
							uni.switchTab({
								url: '/pages/classify/classify'
							})
						}
					}
					// else{
					// 	uni.reLaunch({
					// 		url: '/pages/login/login'
					// 	})
					// }
				}, 1500)
				// #endif
			} else {
				if (uni.getStorageSync('is_open')) {
					uni.switchTab({
						url: '/pages/merchant/merchant'
					})
				}
				// 箭牌小程序定制功能，只显示四个栏目，不显示商城，那么这里判断直接跳转tabbar第一个栏目
				// #ifdef MP-WEIXIN
				if (uni.getExtConfigSync().appid === 'wx9f2da8a90bb750f7') {
					uni.switchTab({
						url: '/pages/merchant/merchant'
					})
				}
				// #endif
				// 解决部分机型点击分享卡片进入不会重新执行绑定的问题
				if (this.parent_id) {
					this.$u.api.binding_refer({
						id: this.parent_id
					}).catch(() => {
						console.log('接口报错：绑定失败')
					})
				}
			}
			// if (uni.getStorageSync('userInfo')) {
			// 	this.$u.apiWei.UserInfo().then(res => {
			// 		if (!res.datas.role_label) {
			// 			uni.navigateTo({
			// 				animationDuration: 500,
			// 				url: '/my/user-label/user-label'
			// 			})
			// 		}
			// 	})
			// }
		},
		onPageScroll(e) {
			if (this.isCustom) {
				if (e.scrollTop > 50) {
					if (this.background.backgroundColor != this.head_bg) {
						this.background.backgroundColor = this.head_bg
					}
				} else {
					if (this.background.backgroundColor !== 'transparent') {
						this.background.backgroundColor = 'transparent'
					}
				}
			}
		},
		onPullDownRefresh() {
			Object.assign(this.$data, this.$options.data())
			this.Refresh = true
			setTimeout(() => {
				this.getHome()
				if (uni.getStorageSync('userInfo')) {
					this.isLogin = true
				}
				this.IndexKillList()
				this.init()
			}, 500)
		},
		methods: {
			// 解析小程序scene参数
			filterUrlParam(urlSearch) {
				let ret = {}
				let regParam = /([^&=]+)=([\w\W]*?)(&|$|#)/g
				if (urlSearch) {
					var strParam = urlSearch;
					var result
					while ((result = regParam.exec(strParam)) != null) {
						ret[result[1]] = result[2]
					}
				}
				return ret
			},
			//获取自定义主题
			getCustomThen() {
				this.$u.api.get_index().then(res => {
					if (res.datas.is_show == 1) {
						this.isCustom = true
						this.head_img = res.datas.head_img
						this.background.backgroundColor = 'transparent'
						this.tabsBackgroundColor = 'transparent'
						this.titleColor = '#FFFFFF'
						this.tabsColor = res.datas.head_txt_color2
						this.tabsActiveColor = res.datas.head_txt_color1
						this.head_bg = res.datas.head_txt_color3
						this.customColor = res.datas.icon.txt_color
						this.customSize = res.datas.icon.img_size.toString()
						uni.setStorageSync('tabbarIcons', res.datas.bottom)
						if (res.datas.bottom_before) {
							uni.setStorageSync('tabbarIconsBefore', res.datas.bottom_before)
							if (uni.getStorageSync('userInfo')) {
								this.tabbarList[0].iconPath = res.datas.bottom_before.img1
								this.tabbarList[1].iconPath = res.datas.bottom_before.img2
								this.tabbarList[2].iconPath = res.datas.bottom_before.img3
								this.tabbarList[3].iconPath = res.datas.bottom_before.img4
								this.tabbarList[4].iconPath = res.datas.bottom_before.img5
							} else {
								this.tabbarList[0].iconPath = res.datas.bottom_before.img1
								this.tabbarList[1].iconPath = res.datas.bottom_before.img2
								this.tabbarList[2].iconPath = res.datas.bottom_before.img4
								this.tabbarList[3].iconPath = res.datas.bottom_before.img5
							}
						}
						this.tabbarList[0].selectedIconPath = res.datas.bottom.img1
						this.indexStep.forEach((item, index) => {
							switch (Number(index)) {
								case 0:
									item.image = res.datas.icon.img1
									break;
								case 1:
									item.image = res.datas.icon.img2
									break;
								case 2:
									item.image = res.datas.icon.img3
									break;
								case 3:
									item.image = res.datas.icon.img4
									break;
							}
						})
						setTimeout(() => {
							uni.setNavigationBarColor({
								frontColor: '#ffffff',
								backgroundColor: ''
							})
						}, 200)
					} else {
						this.isCustom = false
						this.head_img = ''
						this.background.backgroundColor = '#F8F8F8'
						this.titleColor = '#000000'
						this.tabsActiveColor = '#141414'
						this.tabsColor = '#666666'
						this.tabsBackgroundColor = '#F8F8F8'
						this.head_bg = ''
						uni.removeStorageSync('tabbarIcons')
						uni.removeStorageSync('tabbarIconsBefore')
						setTimeout(() => {
							uni.setNavigationBarColor({
								frontColor: '#000000',
								backgroundColor: ''
							})
						}, 200)
					}
				}).then(() => {
					this.$nextTick(() => {
						uni.createSelectorQuery().in(this).select('.index-custom-theme').boundingClientRect(res => {
							this.head_img_height = res.height - 15
						}).exec()
					})
				})
			},
			// 关闭推送弹窗事件
			closeEventsPop(e) {
				if (!e.show) {
					if (this.userInfo) {
						this.getNotice()
					}
				}
			},
			getNotice() {
				if (this.userInfo.role_type == 8 || this.userInfo.role_type == 10 || this.userInfo.role_type == 12) {
					this.$u.api.GetAsk().then(res => {
						if (res.datas != 0) {
							uni.showModal({
								title: '温馨提示',
								content: '您有' + res.datas + '条消息未处理，请前往处理',
								showCancel: false,
								success: (res) => {
									if (res.confirm) {
										uni.navigateTo({
											animationDuration: 500,
											url: '/my/user-reply/user-reply'
										})
									}
								}
							})
						}
					})
				}
			},
			getHome() {
				this.tabbarList = getApp().globalData.merchantMenu
				// // 获取是否显示商户主页
				// if (uni.getStorageSync('userInfo')) {
				// 	if (uni.getStorageSync('is_open')) {
				// 		this.tabbarList = getApp().globalData.arrowMerchantMenu
				// 	} else {
				// 		// #ifdef MP-WEIXIN
				// 		if (uni.getExtConfigSync().appid === 'wx9f2da8a90bb750f7') {
				// 			this.tabbarList = getApp().globalData.merchantMenu.slice(1)
				// 		} else {
				// 			this.tabbarList = getApp().globalData.merchantMenu
				// 		}
				// 		// #endif
				// 		// #ifdef APP-PLUS || H5
				// 		this.tabbarList = getApp().globalData.merchantMenu
				// 		// #endif
				// 	}
				// 	this.$u.api.ShowHome().then(res => {
				// 		let userInfo = JSON.parse(uni.getStorageSync('userInfo'))
				// 		if (userInfo.store_id != res.datas.store_id) {
				// 			userInfo.store_id = res.datas.store_id
				// 			this.userInfo.store_id = res.datas.store_id
				// 		}
				// 		this.userInfo.store_name = res.datas.store_name
				// 		this.userInfo.nickname = res.datas.user.nickname
				// 		this.userInfo.heard_img = res.datas.user.heard_img
				// 		uni.setStorageSync('userInfo', JSON.stringify(userInfo))
				// 		if (res.datas.is_open == 1) {
				// 			this.tabbarList = getApp().globalData.arrowMerchantMenu
				// 			uni.setStorageSync('is_open', true)
				// 		} else {
				// 			uni.setStorageSync('is_open', false)
				// 			// #ifdef MP-WEIXIN
				// 			if (uni.getExtConfigSync().appid === 'wx9f2da8a90bb750f7') {
				// 				this.tabbarList = getApp().globalData.merchantMenu.slice(1)
				// 			} else {
				// 				this.tabbarList = getApp().globalData.merchantMenu
				// 			}
				// 			// #endif
				// 			// #ifdef APP-PLUS || H5
				// 			this.tabbarList = getApp().globalData.merchantMenu
				// 			// #endif
				// 		}
				// 	})
				// 	this.$u.api.UserNoticeCount().then(res => {
				// 		if (res.datas) {
				// 			this.$set(this.tabbarList[this.tabbarList.length - 1], 'count', res.datas)
				// 		} else {
				// 			this.$set(this.tabbarList[this.tabbarList.length - 1], 'count', 0)
				// 		}
				// 	})
				// } else {
				// 	// #ifdef MP-WEIXIN
				// 	if (uni.getExtConfigSync().appid === 'wx9f2da8a90bb750f7') {
				// 		this.tabbarList = getApp().globalData.defaultMenu.slice(1)
				// 	} else {
				// 		this.tabbarList = getApp().globalData.defaultMenu
				// 	}
				// 	// #endif
				// 	// #ifdef APP-PLUS || H5
				// 	this.tabbarList = getApp().globalData.defaultMenu
				// 	// #endif
				// }
			},
			getShare() {
				let data = {
					paramter: 1,
					store_id: uni.getStorageSync('userInfo') ? JSON.parse(uni.getStorageSync('userInfo')).store_id : 1
				}
				this.$u.api.StoreInfo(data).then(res => {
					let obj = {
						service_code: res.datas[0].store_service_code || res.datas[0].service_code,
						service_phone: res.datas[0].store_service_phone
					}
					uni.setStorageSync('serviceInfo', obj)
					let user_id = uni.getStorageSync('userInfo') ? JSON.parse(uni.getStorageSync('userInfo')).user_id : 0
					this.$u.mpShare = {
						title: res.datas[0].store_data.share_txt,
						path: '/pages/index/index?parent_id=' + user_id,
						imageUrl: res.datas[0].store_data.share_images
					}
				})
			},
			// app wgt热更新及手动更新
			Update() {
				let _this = this
				let version = ''
				plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) {
					let version = widgetInfo.version
					_this.$u.api.Appupdate().then(res => {
						if (version !== res.datas.ver) {
							if (res.datas.flag && res.datas.wgtUrl) {
								uni.showLoading({
									mask: true,
									title: '正在更新'
								})
								uni.downloadFile({
									url: res.datas.wgtUrl,
									success: (downloadResult) => {
										if (downloadResult.statusCode === 200) {
											plus.runtime.install(downloadResult.tempFilePath, {
												force: false
											}, function(e) {
												uni.hideLoading()
												console.log('更新成功', e);
												plus.runtime.restart();
											}, function(e) {
												let data = {
													message: '更新失败',
													path: 'index',
													info: e
												}
												this.$u.api.SetError(data)
												uni.showModal({
													title: '温馨提示',
													content: '自动更新失败,请删除后重新下载，感谢您的谅解!',
													showCancel: false,
													success: () => {
														if (uni.getSystemInfoSync().platform === 'ios') {
															plus.runtime.openURL(
																'itms-apps://itunes.apple.com/us/app//id1454079163?l=zh&ls=1&mt=8'
															);
														} else {
															plus.runtime.openURL(this.downLoadUrl);
														}
													}
												})
											})
										}
									},
									fail: (fail) => {
										uni.showToast({
											icon: 'none',
											title: '文件下载失败,请删除应用后重新下载'
										})
									}
								})
							} else if (res.datas.flag && res.datas.pkgUrl) {
								_this.downLoadUrl = res.pkgUrl
								_this.$refs.Update.open()
							}
						}
					})
				})
			},
			updateApp() {
				if (uni.getSystemInfoSync().platform === 'ios') {
					plus.runtime.openURL('itms-apps://itunes.apple.com/us/app//id1454079163?l=zh&ls=1&mt=8');
				} else {
					plus.runtime.openURL(this.downLoadUrl);
				}
			},
			closeUpdate() {
				this.$refs.Update.close()
			},
			async getStoreInfo(){
				if (this.userInfo.token) {
					const res = await this.$u.apiWei.UserInfo()
					this.userInfo = res.datas
					let storeInfo = await this.$u.api.StoreInfo({
						paramter: 1,
						store_id: res.datas.store_id || 1
					})
					this.storeInfo = storeInfo.datas[0]
					uni.setNavigationBarTitle({
						title: this.storeInfo.store_name
					})
				}
			},
			// 初始化获取首页所有数据
			init() {
				this.userInfo = uni.getStorageSync('userInfo') ? JSON.parse(uni.getStorageSync('userInfo')) : {
					store_name: '深哥家居'
				}
				uni.setNavigationBarTitle({
					title: this.userInfo.store_name
				})
				this.$u.api.Index().then(async res => {
					res.datas.style_list.forEach((item, i) => {
						if (item.images_list.length) {
							item.images_list.forEach((data, y) => {
								data.pages = y + 1 + '/' + item.images_list.length
								data.name = item.name
								data.index = i
								this.packageSwiperList.push(data)
							})
						}
						item.length = item.images_list.length
					})
					this.packageList = res.datas.style_list
					this.indexStep = res.datas.tab_list.index_tab
					this.classifyXList = res.datas.tab_list.space_list
					this.tab_list = res.datas.tab_list.wx_tab_list
					this.shelf_list = res.datas.shelf_list
					this.advertising = res.datas.advertising
					this.square_data = res.datas.square_data
					res.datas.shelf_list.forEach(item => {
						if (item.type == 6) {
							this.brandList = item.data[0].shelf_tab
						}
					})
					this.getStoreInfo()
					// const {
					// 	datas
					// } = await this.$u.api.SeniorList({
					// 	senior_id: 1
					// })
					// this.seniorImg = datas.cover_img
				}).then(() => {
					this.show = true
					// #ifdef MP-WEIXIN || APP-PLUS
					if (this.userInfo.token) {
						this.$nextTick(async () => {
							// // #ifdef MP-WEIXIN
							// if ((!this.userInfo.nickname && !this.userInfo.heard_img) || !this.userInfo.form_id) {
							// 	this.$refs.bindUserInfo.open()
							// } else if ((this.userInfo.nickname == 0 && this.userInfo.heard_img == 0) || !this.userInfo
							// 	.form_id) {
							// 	this.$refs.bindUserInfo.open()
							// }
							// // #endif
							// // #ifdef APP-PLUS
							// if (!this.userInfo.nickname && !this.userInfo.heard_img) {
							// 	this.$refs.bindUserInfo.open()
							// } else if (this.userInfo.nickname == 0 && this.userInfo.heard_img == 0) {
							// 	this.$refs.bindUserInfo.open()
							// }
							// // #endif
						}, 200)
					}
					// #endif
					this.$nextTick(() => {
						uni.createSelectorQuery().in(this).select('.navbar').boundingClientRect(res => {
							if (res) {
								this.top = res.height + 10
							}
						}).exec()
						if (uni.getStorageSync('userInfo')) {
							this.getShare()
						}
					}, 200)
					this.getRecomment()
					if (this.Refresh) {
						// #ifdef MP-WEIXIN
						this.packageIndex = 0
						this.packageCurrent = 0
						// #endif
						this.Refresh = false
						uni.stopPullDownRefresh({
							success: () => {
								this.$forceUpdate();
								uni.showToast({
									icon: 'none',
									title: '刷新成功'
								})
							}
						})
					}
					this.getCustomThen()
				}).catch(res => {
					console.log(res)
					if (res.code) {
						switch (Number(res.code)) {
							case 201:
								uni.showToast({
									icon: 'none',
									title: '请先登录',
									duration: 1500
								})
								break;
							default:
								uni.showToast({
									icon: 'none',
									title: res.error
								})
								break;
						}
						return false
					}
					uni.showToast({
						icon: 'none',
						title: '加载失败,请下拉刷新重试!'
					})
				})
			},
			getRecomment() {
				this.$u.api.IndexGoodsRecommend({
					space_id: this.space_id,
					class_list: this.class_list.length ? JSON.stringify(this.class_list) : '',
					limit: this.limit,
				}).then(res => {
					if (this.space_id) {
						this.isLoad = false
						res.datas.list.forEach((item, y) => {
							if (this.index == y) {
								item.space_list.forEach((data, i) => {
									if (data.space_id == this.space_id) {
										this.$set(item, 'productsIndex', i)
									}
								})
							}
						})
					}
					this.boutique = res.datas
				})
			},
			packageTabChange(index) {
				this.packageIndex = index
				let number = 0
				this.packageList.forEach((item, x) => {
					if (x < index) {
						number += item.images_list.length
					}
				})
				// #ifdef APP-PLUS || MP-WEIXIN
				this.packageCurrent = number // APP或者微信小程序版此参数为Number
				// #endif
				// #ifdef H5
				this.packageCurrent = number.toString() // H5版此参数为string
				// #endif
			},
			packageChange(e) {
				// #ifdef APP-PLUS || MP-WEIXIN
				this.packageCurrent = e
				// #endif
				// #ifdef H5
				this.packageCurrent = e.toString()
				// #endif
				this.packageIndex = this.packageSwiperList[e].index
			},
			search() {
				uni.navigateTo({
					url: '/pages/search/search',
					animationDuration: 500,
					animationType: 'slide-in-bottom'
				})
				if (uni.getStorageSync('userInfo')) {
					this.addFoot('首页-搜索')
				}
			},
			imgSearch() {
				uni.chooseImage({
					count: 1,
					sizeType: ["original", "compressed"],
					sourceType: ["album", "camera"],
					success: (choseRes) => {
						uni.uploadFile({
							url: this.action,
							filePath: choseRes.tempFilePaths[0],
							name: 'file',
							formData: this.formData,
							success: (imgUrl) => {
								uni.navigateTo({
									animationDuration: 500,
									url: '/pages/search/search-result?url=' + JSON.parse(imgUrl.data).datas[0]
								})
							}
						})
					}
				})
			},
			morePackage(type) {
				let packageType = null
				if (type == 1) {
					packageType = 2
				} else {
					packageType = 1
				}
				if (type == 24) {
					uni.navigateTo({
						animationDuration: 500,
						url: '/special-package/list/list'
					})
					return
				}
				uni.navigateTo({
					animationDuration: 500,
					url: '/pages/package/package?is_shelf=true&type=' + packageType
				})
			},
			// 更多推荐
			Recommend(shelf_id, type, name, is_meal, data) {
				if (is_meal && is_meal == 4) {
					uni.navigateToMiniProgram({
						appId: data.app_id,
						path: data.app_link
					})
					return
				}
				if (type) {
					switch (Number(type)) {
						case -1:
							this.addFoot('首页-' + name + '-列表', '#客户浏览' + name + '商品，建议给客户推荐最新' + name + '商品')
							break;
						case 3:
						case 11:
						case 12:
						case 13:
							this.addFoot('首页-货架-' + name, '#客户浏览' + name + '商品，建议给客户推荐最新' + name + '商品')
							break;
						case 5:
							this.addFoot('首页-货架-新品专区-列表', '#客户浏览' + name + '商品，建议给客户推荐最新商品')
							break;
					}
				}
				if (type == 3 || type == 5 || type == 11 || type == 12 || type == 13) {
					uni.navigateTo({
						url: '/pages/recommendList/recommendList?is_shelf=true&shelf_id=' + shelf_id,
						animationDuration: 500
					})
				}
				// else if(shelf_id==37){
				// 	uni.navigateTo({
				// 		url: '/events/hot-list?is_home_jump=true&shelf_id=' + shelf_id,
				// 		animationDuration: 500
				// 	})
				// }
				else {
					uni.navigateTo({
						url: '/pages/recommendList/recommendList?is_home_jump=true&shelf_id=' + shelf_id,
						animationDuration: 500
					})
				}
			},
			// 更多品牌
			moreBrand() {
				this.addFoot('首页-货架-品牌推荐-列表')
				uni.navigateTo({
					url: '/brand-list/brand-list',
					animationDuration: 500
				})
			},
			// 选择品牌类型
			changeBrandType(e, list) {
				this.brandIndex = e
				this.brandList = list
			},
			moreVr(type) {
				if (type == 7) {
					this.addFoot('首页-货架-VR-列表', '#客户浏览VR推荐，请保持跟进')
					uni.navigateTo({
						animationDuration: 500,
						url: '/pages/case/case?is_shelf=true'
					})
				} else {
					this.addFoot('首页-货架-案例-列表', '#客户浏览案例推荐，请保持跟进')
					uni.navigateTo({
						animationDuration: 500,
						url: '/pages/case-list/case-list?is_shelf=true'
					})
				}
			},
			goVrInfo(vr_id, type) {
				if (type == 7) {
					uni.navigateTo({
						animationDuration: 500,
						url: '/pages/vr-info/vr-info?vr_id=' + vr_id
					})
					this.addFoot('首页-货架-Vr-详情', '#客户浏览Vr推荐，请保持跟进')
				}
				if (type == 10) {
					uni.navigateTo({
						animationDuration: 500,
						url: '/pages/case-list/case-details/case-details?case_id=' + vr_id
					})
					this.addFoot('首页-货架-案例-详情', '#客户浏览案例推荐，请保持跟进')
				}
			},
			// 切换精品推荐分类
			productsTabChange(e, index, data) {
				if (e) {
					this.limit = 19
				} else {
					this.limit = 9
				}
				this.index = index
				this.space_id = data[e].space_id
				this.getRecomment()
			},
			goClass(e, i, shelf_id) {
				if (e[0]) {
					this.$set(this.class_id[i], 'space_id', e[1])
					this.$set(this.class_id[i], 'class_id', e[0])
				} else {
					this.$set(this.class_id[i], 'space_id', '')
					this.$set(this.class_id[i], 'class_id', '')
				}
				this.class_list = []
				this.class_id.forEach(item => {
					if (item.space_id && item.class_id) {
						this.class_list.push(item)
					}
				})
				this.getRecomment()
			},
			jumpSpaceList(e) {
				console.log(e)
				switch (Number(e[0])) {
					case 1:
						uni.navigateTo({
							animationDuration: 500,
							url: '/pages/package/package?type=1&is_home_jump=true'
						})
						break;
					case 2:
						uni.navigateTo({
							animationDuration: 500,
							url: '/pages/package/package?type=2&is_home_jump=true'
						})
						break;
					case 8:
						uni.navigateTo({
							animationDuration: 500,
							url: '/pages/recommendList/recommendList?is_home_jump=true&shelf_id=' + e[1]
						})
						break;
					default:
						uni.navigateTo({
							animationDuration: 500,
							url: '/pages/class-products/class-products?shelf_id=' + e[1] + '&is_home_jump=true'
						})
						break;
				}
				if (uni.getStorageSync('userInfo')) {
					this.addFoot('首页-空间-' + e[2].name, '#客户浏览' + e[2].name + '商品，建议给客户推荐热销' + e[2].name + '商品')
				}
			},
			// 点击轮播图
			goStyleList(e) {
				if (this.packageSwiperList[e].is_house == 4) {
					uni.navigateToMiniProgram({
						appId: this.packageSwiperList[e].app_id
					})
				} else if (this.packageSwiperList[e].link) {
					// #ifdef H5
					window.open(this.packageSwiperList[e].link)
					// #endif
					// #ifdef MP-WEIXIN || APP-PLUS
					uni.navigateTo({
						animationDuration: 500,
						url: '/pages/webview/webview?url=' + encodeURIComponent(this.packageSwiperList[e].link)
					})
					// #endif
				} else if (this.packageSwiperList[e].factory_id) {
					uni.navigateTo({
						animationDuration: 500,
						url: '/brand-list/brand-info/brand-info?type=2&factory_id=' + this.packageSwiperList[e].factory_id +
							'&style_id=' + this.packageSwiperList[e].styleId
					})
				} else if (!this.packageSwiperList[e].factory_id && this.packageSwiperList[e].is_house == 0) {
					uni.navigateTo({
						animationDuration: 500,
						url: '/brand-list/brand-info/brand-info?type=2&style_id=' + this.packageSwiperList[e].styleId +
							'&style_name=' + this.packageSwiperList[e].style_name
					})
				} else if (this.packageSwiperList[e].is_house != 0) {
					if (this.packageSwiperList[e].group_id && this.packageSwiperList[e].group_id != 0 && this.packageSwiperList[e]
						.is_house == 1) {
						uni.navigateTo({
							animationDuration: 500,
							url: '/pages/package/house-info?group_id=' + this.packageSwiperList[e].group_id
						})
					} else if (this.packageSwiperList[e].group_id && this.packageSwiperList[e].group_id != 0 && this
						.packageSwiperList[e].is_house == 2) {
						uni.navigateTo({
							animationDuration: 500,
							url: '/pages/package/n98-info?group_id=' + this.packageSwiperList[e].group_id
						})
					} else if (this.packageSwiperList[e].is_house == 3) {
						uni.navigateTo({
							animationDuration: 500,
							url: this.packageSwiperList[e].factory_sn
						})
					} else {
						uni.navigateTo({
							animationDuration: 500,
							url: '/pages/package/package?type=' + this.packageSwiperList[e].is_house
						})
					}
				}
				if (uni.getStorageSync('userInfo')) {
					this.addFoot('首页-轮播图-' + this.packageSwiperList[e].name + '-' + this.packageSwiperList[e].title, '#客户浏览' + this
						.packageSwiperList[e].item + '轮播图，请保持跟进')
				}
			},
			goCar() {
				uni.switchTab({
					animationDuration: 500,
					url: '/pages/car/car'
				})
				if (uni.getStorageSync('userInfo')) {
					this.addFoot('首页-购物车', '#客户查看了购物车，保持关注，努力促成交易，获取更多业绩!')
				}
			},
			moreProducts(e) {
				uni.switchTab({
					url: '/pages/classify/classify'
				})
			},
			moreSpace(e) {
				uni.navigateTo({
					animationDuration: 500,
					url: '/pages/class-products/class-products?shelf_id=' + e[0]
				})
				if (uni.getStorageSync('userInfo')) {
					this.addFoot('首页-货架-精品推荐-' + e[0] + '-列表', '#客户浏精品推荐商品，建议给客户推荐相关精选商品')
				}
			},
			// 足迹
			addFoot(where, detail) {
				this.$u.api.AddFoot({
					// #ifdef MP-WEIXIN
					type: 1,
					// #endif
					// #ifdef APP-PLUS
					type: 2,
					// #endif
					// #ifdef H5
					type: 3,
					// #endif
					store_id: uni.getStorageSync('userInfo') ? JSON.parse(uni.getStorageSync('userInfo')).store_id : '',
					client: 1,
					where: where,
					stay_time: this.addFootParam.stay_time,
					goods_id: 0,
					store_goods_id: 0,
					is_new: 1,
					detail: detail ? detail : ''
				})
			},
			goEvent(e) {
				let item = this.eventsList[e]
				if (uni.getStorageSync('userInfo')) {
					this.addFoot('首页-弹窗-' + item.name)
				}
				switch (Number(item.type)) {
					case 0:
						break;
					case 1:
						uni.navigateTo({
							animationDuration: 500,
							url: '/pages/product-info/product-info?goods_id=' + item.id
						})
						break;
					case 2:
						uni.navigateTo({
							animationDuration: 500,
							url: '/pages/package/n98-info?group_id=' + item.id
						})
						break;
					case 3:
						uni.navigateTo({
							animationDuration: 500,
							url: '/pages/package/house-info?group_id=' + item.id
						})
						break;
					case 4:
						uni.navigateTo({
							animationDuration: 500,
							url: item.id
						})
						break;
					case 5:
						uni.navigateTo({
							animationDuration: 500,
							url: '/pages/recommendList/recommendList?shelf_id=' + item.id
						})
						break;
					case 6:
						uni.navigateTo({
							animationDuration: 500,
							url: '/pages/search/search-result'
						})
						break;
					case 7:
						// #ifdef H5
						window.open(item.id)
						// #endif
						// #ifdef MP-WEIXIN || APP-PLUS
						uni.navigateTo({
							animationDuration: 500,
							url: '/pages/webview/webview?url=' + encodeURIComponent(item.id)
						})
						// #endif
						break;
				}
			},
			goUrl(e) {
				if (e) {
					uni.navigateTo({
						animationDuration: 500,
						url: e
					})
					if (uni.getStorageSync('userInfo')) {
						this.addFoot('首页-广告位')
					}
				}
			},
			loadUpDateImg(e) {
				this.UpDateImgHeight = e.detail.height - 151
			},
			bindwx() {
				// #ifdef MP-WEIXIN
				uni.getUserProfile({
					desc: '用户完善会员资料',
					success: (userInfo) => {
						uni.login({
							provider: 'weixin',
							success: (loginRes) => {
								this.code = loginRes.code
								let data = {
									code: this.code,
									// parent_id: uni.getStorageSync('parent_id')?uni.getStorageSync('parent_id'):'',
									encryptedData: userInfo.encryptedData,
									iv: userInfo.iv,
									phone: JSON.parse(uni.getStorageSync('userInfo')).phone
								}
								this.$u.api.WxChatWxGetUserInfo(data).then(res => {
									uni.showToast({
										icon: 'none',
										title: '绑定成功'
									})
									this.$refs.bindUserInfo.close()
									uni.setStorageSync('userInfo', JSON.stringify(res.datas))
								})
							}
						})
					},
					fail: (fail) => {
						console.log(fail)
					}
				})
				// #endif
				// #ifdef APP-PLUS
				let _this = this
				let weixinService = null;
				plus.oauth.getServices((services) => {
					services.forEach(item => {
						if (item.id === 'weixin') {
							weixinService = item
						}
					})
					if (!weixinService) {
						uni.showToast({
							icon: 'none',
							title: '没有微信授权服务'
						})
						return;
					}
					weixinService.authorize((e) => {
						_this.$u.api.NewAppBinding({
							code: e.code,
							phone: JSON.parse(uni.getStorageSync('userInfo')).phone,
							type: 2,
						}).then(res => {
							uni.setStorageSync('userInfo', JSON.stringify(res.datas))
							uni.showToast({
								icon: 'none',
								title: '绑定成功'
							})
							this.$refs.bindUserInfo.close()
						})
					})
				})
				// #endif
			},
			goTieIn() {
				uni.navigateTo({
					animationDuration: 500,
					url: '/tie-in/tie-in'
				})
			},
			packageAddFoot(type) {
				if (uni.getStorageSync('userInfo')) {
					if (type == 1) {
						this.addFoot('货架-全屋-详情', '#客户浏览N98套餐，请保持跟进')
					} else if (type == 2) {
						this.addFoot('货架-N98套餐-详情', '#客户浏览N98套餐，请保持跟进')
					}
				}
			},
			GoInfoAddFoot(name) {
				if (uni.getStorageSync('userInfo')) {
					this.addFoot('首页-货架-' + name + '-商品详情', '#客户浏览' + name + '商品，建议给客户推荐' + name + '相关商品')
				}
			},
			GoRecommentInfoAddFoot() {
				if (uni.getStorageSync('userInfo')) {
					this.addFoot('货架-精品推荐-商品详情', '#客户浏精品推荐商品，建议给客户推荐相关精选商品')
				}
			},
			brandAddFoot(e) {
				if (uni.getStorageSync('userInfo')) {
					let name
					if (this.brandIndex == 0) {
						name = '甄选'
					} else if (this.brandIndex == 1) {
						name = '严选'
					} else if (this.brandIndex == 2) {
						name = '十大'
					}
					this.addFoot('首页-货架-品牌推荐-' + name + '-' + e, '#客户浏览' + name + '品牌商品，建议给客户推荐相关品牌优质商品')
				}
			},
			goCourse() {
				uni.navigateTo({
					animationDuration: 500,
					url: '/my/user-course/user-course'
				})
			},
			moreSquare() {
				uni.navigateTo({
					animationDuration: 500,
					url: '/square/square-list'
				})
			},
			goSquareInfo(id) {
				uni.navigateTo({
					animationDuration: 500,
					url: '/square/square-info?square_id=' + id
				})
				this.addFoot('首页-家居广场-详情', id)
			},
			async IndexKillList() {
				const {
					datas
				} = await this.$u.api.IndexKillList()
				this.killData = datas.shelf_list[0]
				this.killCountDown = datas.shelf_list[0].stop_time - new Date().getTime() / 1000
			},
			goProductInfo(goods_id) {
				getApp().goProInfo(goods_id)
			},
			goAdvanced() {
				uni.navigateTo({
					animationDuration: 500,
					url: '/events/advanced'
				})
			},
			goStoreInfo(){
				uni.navigateTo({
					animationDuration: 500,
					url: `/merchant/store-info/store-info?store_id=${this.storeInfo.store_id}`
				})
			},
			goStorePoster(){
				uni.navigateTo({
					animationDuration: 500,
					url: `/pages/store-poster/store-poster?store_id=${this.storeInfo.store_id}`
				})
			},
		},
		mounted() {
			// #ifdef MP-WEIXIN
			uni.login({
				provider: 'weixin',
				success: (loginRes) => {
					this.code = loginRes.code
				}
			})
			// #endif
		},
		onHide() {
			this.addFootParam.end_time = parseInt(new Date().getTime() / 1000)
			this.addFootParam.stay_time = this.addFootParam.end_time - this.addFootParam.start_time
			if (uni.getStorageSync('userInfo')) {
				this.addFoot('查看首页')
			}
		},
		computed: {
			cusTomBackground() {
				if (this.isCustom) {
					return 'background-color: transparent; padding-bottom: 30rpx'
				} else {
					return 'background-color: #F8F8F8'
				}
			},
			cusTomBottom() {
				if (this.isCustom) {
					return 'bottom: -52rpx'
				}
			},
			cusTomPaddingBottom() {
				if (this.isCustom) {
					return 'padding-bottom: 30rpx'
				}
			}
		}
	}
</script>

<style lang="scss">
	
	.store-info{
		padding: 30rpx;
		border-radius: 20rpx;
		background-color: #F8F8F8;
		position: relative;
		&-top{
			background-color: #FFF;
			border-radius: 20rpx 20rpx 0 0;
			display: flex;
			align-items: flex-start;
			padding: 30rpx;
			image.logo{
				width: 96rpx;
				height: 96rpx;
				border-radius: 50%;
				border: solid 2rpx #eee;
			}
			.store-info-right{
				flex: 1;
				min-width: 0;
				margin-left: 42rpx;
				.store-name{
					display: flex;
					align-items: center;
					justify-content: space-between;
					.name{
						font-weight: bold;
						font-size: 34rpx;
					}
					.phone{
						display: flex;
						align-items: center;
						font-size: 24rpx;
						image{
							width: 19rpx;
							height: 19rpx;
							margin-right: 6rpx;
						}
					}
				}
				.store-address{
					font-size: 24rpx;
					color: #666;
					margin-top: 10rpx;
					line-height: 32rpx;
				}
			}
		}
		&-bot{
			border-radius: 0 0 20rpx 20rpx;
			height: 46rpx;
			background: rgba(245,147,89,0.16);
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 24rpx;
			.enter{
				flex: 1;
				min-width: 0;
				text-align: center;
				display: flex;
				align-items: center;
				justify-content: center;
				height: 46rpx;
				image{
					width: 24rpx;
					height: 24rpx;
					margin-right: 6rpx;
				}
			}
		}
	}
	.scanning {
		width: 40rpx;
		height: 40rpx;
		margin-left: 30rpx;
	}

	.search {
		width: 40rpx;
		height: 40rpx;
		margin-right: 30rpx;
		/* #ifdef MP-WEIXIN */
		margin-right: 0;
		margin-left: 30rpx;
		/* #endif */
	}

	.index {
		.advanced-enter {
			padding: 0 30rpx 30rpx;
			background-color: #F8F8F8;

			image {
				width: 100%;
			}
		}

		.index-square-list {
			display: flex;
			padding: 0 30rpx 60rpx;

			.index-square-item {
				width: 210rpx;
				position: relative;
				margin-right: 30rpx;

				&:nth-child(3n) {
					margin-right: 0;
				}

				.view-times {
					position: absolute;
					top: 10rpx;
					left: 10rpx;
					z-index: 10;
					background-color: rgba(0, 0, 0, 1);
					color: #FFF;
					opacity: .3;
					border-radius: 30rpx;
					padding: 0 10rpx;
					font-size: 20rpx;
					display: flex;
					align-items: center;
					line-height: 32rpx;

					/deep/ .u-icon {
						margin-right: 5rpx;
					}
				}

				image {
					width: 210rpx;
					height: 210rpx;
					border-radius: 8rpx;
				}

				.square-name {
					margin-top: 25rpx;
					font-size: 28rpx;
					color: #141414;
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
				}

				.square-des {
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
					font-size: 22rpx;
					color: #666;
					margin-top: 20rpx;
					line-height: 40rpx;
				}
			}
		}

		.index-custom-theme {
			position: relative;

			.head_img {
				position: absolute;
				width: 100%;
				top: 0;
			}
		}

		.index-package {
			position: relative;

			.shadow {
				position: absolute;
				width: 100%;
				height: 164rpx;
				left: 0;
				bottom: -82rpx;
				z-index: 1;

				image {
					width: 100%;
					height: 164rpx;
				}
			}
		}

		.z-index {
			z-index: 2;
		}

		.index-package-swiper {
			position: relative;
			padding-top: 30rpx;
			background-color: #F8F8F8;
		}

		.index-step {
			background-color: #F8F8F8;
			margin-top: -30rpx;
		}

		.index-classify-x {
			padding-left: 30rpx;
			background-color: #F8F8F8;
		}

		.top-brand-img {
			padding: 0 30rpx;
			margin-top: 30rpx;
			background-color: #F8F8F8;

			image {
				width: 100%;
			}
		}

		.index-area {
			background-color: #F8F8F8;
			padding: 30rpx;
			display: flex;
			align-items: center;

			.index-area-left {
				width: 360rpx;
				height: 560rpx;
				background: linear-gradient(to bottom, #ECD1B0, #E0B989);
				border-radius: 8rpx;
				margin-right: 20rpx;
				padding: 20rpx;

				.skill-tit {
					display: flex;
					align-items: center;
					justify-content: space-between;

					.name {
						font-size: 36rpx;
						font-weight: bold;
					}
				}

				.count-down {
					margin-top: 14rpx;
				}

				.skill-more {
					line-height: 44rpx;
					width: 100rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					font-size: 24rpx;
					color: #6A3F0A;
					border: solid 2rpx rgba(106, 63, 10, .3);
					border-radius: 44rpx;

					&::after {
						content: '';
						width: 0;
						height: 0;
						border-top: 10rpx solid transparent;
						border-bottom: 10rpx solid transparent;
						border-left: 10rpx solid #6A3F0A;
						margin-left: 6rpx;
					}
				}

				.skill-item {
					margin-top: 20rpx;
					padding: 10rpx;
					background-color: #FFF;
					border-radius: 10rpx;
					display: flex;
					align-items: center;

					image {
						width: 100rpx;
						height: 100rpx;
						border-radius: 10rpx;
					}

					.item-info {
						flex: 1;
						min-width: 0;
						margin-left: 10rpx;

						.name {
							white-space: nowrap;
							overflow: hidden;
							text-overflow: ellipsis;
							color: #444;
							font-size: 24rpx;
						}

						.price {
							margin-top: 10rpx;

							.current-price {
								color: #F59359;
								font-size: 28rpx;
								margin-right: 20rpx;

								text {
									font-size: 20rpx;
								}
							}

							.del-price {
								color: #A4A4A4;
								font-size: 23rpx;
								text-decoration: line-through;
							}
						}
					}
				}
			}

			.index-area-right {
				flex: 1;
				min-width: 0;

				.area-right-item {
					margin-bottom: 20rpx;

					&:last-child {
						margin-bottom: 0;
					}

					image {
						width: 100%;
						height: 170rpx;
					}
				}
			}

			.index-area-list {
				position: relative;
				display: flex;
				flex-wrap: wrap;
				background-color: #FFFFFF;
				border-radius: 16rpx;
				overflow: hidden;
				flex: 1;

				.index-area-item {
					width: 50%;

					image {
						width: 100%;
						vertical-align: top;
					}

					&:first-child {
						image {
							border-radius: 16rpx 0 0 0;
						}
					}

					&:nth-child(2) {
						image {
							border-radius: 0 16rpx 0 0;
						}
					}

					&:nth-child(3) {
						image {
							border-radius: 0 0 0 16rpx;
						}
					}

					&:last-child {
						image {
							border-radius: 0 0 16rpx 0;
						}
					}
				}

				&::after {
					content: '';
					position: absolute;
					width: 2rpx;
					height: 100%;
					left: 50%;
					top: 0;
					transform: translateX(-50%);
					background-color: #F6F6F6;
					z-index: 1;
				}

				&::before {
					content: '';
					position: absolute;
					height: 2rpx;
					width: 100%;
					left: 0;
					top: 50%;
					transform: translateY(-50%);
					background-color: #F6F6F6;
					z-index: 1;
				}
			}
		}

		.index-white-raidus {
			background-color: #F8F8F8;

			&::after {
				content: '';
				display: block;
				background-color: #FFF;
				height: 30rpx;
				border-radius: 16rpx 16rpx 0 0;
			}
		}

		.index-recommend {
			.index-recommend-list {
				padding: 0 30rpx 40rpx;
			}
		}

		.index-brand-list {
			padding: 0 30rpx 40rpx;

			.shadow {
				box-shadow: 0rpx 20rpx 40rpx 0 rgba(40, 34, 31, 0.05);
			}

			.index-brand-tabs {
				display: flex;

				.index-brand-tabs-item {
					flex: 1;
					height: 90rpx;
					line-height: 90rpx;
					text-align: center;
					background-color: #F8F8F8;
					font-size: 28rpx;
					color: #666;
					border-right: solid 1px #faf7fa;

					&:last-child {
						border-right: none;
					}

					&.active {
						background-color: #FFF;
						color: #141414;
						font-weight: bold;
					}
				}
			}
		}

		.index-products {
			.index-products-tabs {
				margin-top: -40rpx;
			}

			.index-products-items {
				padding: 0 30rpx;
				border-bottom: solid 1px #F6F6F6;
			}
		}

		.car-btn {
			position: fixed !important;
			left: 0;
			top: 44px;
			bottom: 120rpx;
			left: 5px;
			right: 5px;
			pointer-events: none;
			z-index: 20;
			width: auto;
			height: auto;

			.car-btn-img {
				position: absolute !important;
				width: 80rpx;
				height: 80rpx;
				pointer-events: auto;
				border-radius: 50%;
				top: initial;
				left: initial;
				right: 0;
				bottom: 0;
				bottom: constant(safe-area-inset-bottom);
				bottom: env(safe-area-inset-bottom);
				text-align: center;

				image {
					width: 80rpx;
					height: 80rpx;
				}
			}

			.course-btn-img {
				position: absolute !important;
				width: 80rpx;
				height: 80rpx;
				pointer-events: auto;
				border-radius: 50%;
				top: initial;
				left: initial;
				right: 0;
				bottom: 0;
				bottom: constant(safe-area-inset-bottom);
				bottom: env(safe-area-inset-bottom);
				text-align: center;
				margin-bottom: 100rpx;

				image {
					width: 80rpx;
					height: 80rpx;
				}
			}
		}

		.bindUserInfo {
			button {
				background-color: transparent;
				width: 580rpx;
				height: 725rpx;

				image {
					width: 580rpx;
					height: 725rpx;
				}
			}
		}

		.eventsPop-list {
			width: 600rpx;
		}
	}

	.askPopup-box {
		background-color: #FFF;
		width: 600rpx;
		border-radius: 10rpx;
		padding: 30rpx;
		box-sizing: border-box;
	}

	.update-pop {
		width: 540rpx;
		margin: 0 auto;

		.update-close {
			text-align: right;
			margin-bottom: 30rpx;
			padding-right: 20rpx;

			image {
				width: 58rpx;
				height: 58rpx;
			}
		}

		.update-img {
			width: 100%;
			vertical-align: top;
			background-color: #000;
		}

		.update-main {
			background-color: #FFF;
			border-radius: 0 0 10rpx 10rpx;
			overflow: hidden;
			padding: 40rpx;

			.update-tit {
				margin-bottom: 30rpx;
				font-weight: bold;
				color: #333;
			}

			.update-p {
				margin-bottom: 10rpx;
				color: #666;
			}

			.download {
				display: block;
				margin-top: 30rpx;
				background-color: #141414;
				font-size: 30rpx;
			}
		}
	}
</style>